home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / share / apport / package-hooks / source_gnome-power-manager.py < prev    next >
Encoding:
Python Source  |  2009-04-08  |  1.0 KB  |  34 lines

  1. '''apport package hook for gnome-power-manager
  2.  
  3. (c) 2009 Canonical Ltd.
  4. Author: Steve Beattie <sbeattie@ubuntu.com>
  5. '''
  6.  
  7. from apport.hookutils import *
  8. from os import path
  9.  
  10. def attach_hal_capability_present(report, cap, capid):
  11.     match_error = re.compile("^Error")
  12.     if not match_error.match(hal_find_by_capability(cap)[0]):
  13.         report[capid] = "Present"
  14.         found = True
  15.     else:
  16.         report[capid] = "Not Present"
  17.         found = False
  18.     return found
  19.  
  20. def add_info(report):
  21.     attach_hal_capability_present(report, 'ac_adapter', 'ACAdapter')
  22.     attach_hal_capability_present(report, 'laptop_panel', 'LaptopPanel')
  23.     attach_hal_capability_present(report, 'cpufreq_control', 'CPUScaling')
  24.  
  25.     if attach_hal_capability_present(report, 'battery', 'Battery'):
  26.         battery_info = ''
  27.         for udi in hal_find_by_capability('battery'):
  28.             battery_info += hal_dump_udi(udi)
  29.         report[BatteryInfo] = battery_info
  30.     
  31.     attach_hardware(report) 
  32.  
  33.     attach_gconf(report, 'gnome-power-manager')
  34.